Skip to content

API Explorer for V2 APIs (based on Scalar OpenAPI UI) - #5201

Open
epugh wants to merge 14 commits into
apache:mainfrom
epugh:api-explorer-demo
Open

epugh wants to merge 14 commits into
apache:mainfrom
epugh:api-explorer-demo

Conversation

@epugh

@epugh epugh commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Expose Scalar OpenAPI Explorer ui in our webapp for the V2 APIs.

image

Solution

Scalar is opensource librarby that we have intergrated in a fairly "minimal" fashiong. We leverage the Node tooling so we download the scalar libs at build time, but the whole app lives outside of our Solr Admin UI, in a parralle directory. This was for seperation, but also because our Angular App and the SPA of Scalar fight if they are in the same window. Scalar is embedded as an iframe.

It comumes the current openapi spec.

Tests

manual + a new selenium test.

epugh and others added 3 commits October 22, 2026 21:26
Regenerates the OpenAPI spec, fetches swagger-ui-dist via npm, and drops a
same-origin Swagger UI page into a running `./gradlew dev` instance so you
can "Try it out" against a real local Solr without writing client code.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RzzUgiebQ8ZhhgE2E7ZZU5
Adds a static Swagger UI page at /solr/libs/swagger-ui/, built from the same
OpenAPI spec that feeds the generated SolrJ clients:
 - :solr:webapp now consumes :solr:api's openapiSpec artifact and bakes it
   into the war as spec.json, so it ships in sync with the running version.
 - ApiMetadata now declares a relative `servers: [{url: "/api"}]` entry so
   "Try it out" calls stay same-origin with whichever node serves the page,
   with no CORS setup needed.
 - swagger-ui-dist's bundle/preset/css are vendored under web/libs/swagger-ui/,
   attributed in NOTICE.txt alongside the project's other bundled JS libraries.
 - The init call lives in its own openapi-init.js rather than an inline
   <script>, since Solr's CSP header (script-src 'self', no 'unsafe-inline')
   silently drops inline scripts.
 - Linked from the Admin UI's footer nav (opens in a new tab, parallel to
   the Admin UI rather than embedded in its routing).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RzzUgiebQ8ZhhgE2E7ZZU5
./gradlew :solr:webapp:rat failed on the API Explorer files added in the
previous commit:
 - index.html and openapi-init.js are first-party; they were missing the
   standard ASF header.
 - swagger-ui-bundle.js, swagger-ui-standalone-preset.js, swagger-ui.css, and
   index.css are vendored from swagger-ui-dist unmodified. Webpack strips
   their own and their bundled dependencies' license text out into sibling
   *.LICENSE.txt files rather than leaving a recognizable header in the
   minified output, so RAT can't classify them - excluded by path instead,
   following the precedent set by :solr:server's vendored Jetty config files.

Also vendors the two *.LICENSE.txt files themselves (already covered by the
blanket "**/*.txt" RAT exclude), since they document the MIT/Apache-licensed
third-party code swagger-ui-dist itself bundles.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RzzUgiebQ8ZhhgE2E7ZZU5
@github-actions github-actions Bot added documentation Improvements or additions to documentation tool:build admin-ui cat:api scripts labels Oct 23, 2026
@nick-boss-tech

nick-boss-tech commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Draft Review:

  • License handling is incomplete. Both vendored JavaScript bundles reference missing license files. Precommit also fails :solr:webapp:rat for all six new Swagger UI resources. Add the required headers and upstream notices, then verify the packaged output.
  • Document the shipped explorer URL separately from the developer helper.
  • Replace SOLR-XXXXX and add the changelog.
  • Add a smoke test for the packaged explorer; current tests do not establish that it works.

AI-generated. Details available upon request.

@github-actions github-actions Bot added dependencies Dependency upgrades and removed scripts labels Oct 24, 2026
@epugh epugh changed the title Api explorer demo (based on swagger ui) Api explorer demo (based on Scalar OpenAPI UI) Oct 25, 2026
@epugh
epugh marked this pull request as ready for review October 25, 2026 15:14
@epugh
epugh requested a review from gerlowskija October 25, 2026 15:14
@epugh

epugh commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

I started with Swagger UI, but it was just kind of clunky and old feeling. I found this compatible UI Scalar. Turns out this space has a bunch of new tools like this, all comepting to be your next mcp/llms.txt/etc generating tool! Since this is lightly integrated (just a link from our footer in the admin tool) I htink if it goes dormant, we can eliminate it in a few years pretty easily!

@epugh

epugh commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

@jaykay12 you may be itnerested in this!

@janhoy

janhoy commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

I'm sceptical to vendor-owned open source like this, you never know how long it is truly open, whether their product phones home etc. But if we screen for such things it should not be risky to include. I'd prefer if the UI is just always available on a solr node.

@epugh

epugh commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

I'm sceptical to vendor-owned open source like this, you never know how long it is truly open, whether their product phones home etc. But if we screen for such things it should not be risky to include. I'd prefer if the UI is just always available on a solr node.

Yeah... All of them feel like "a burst of amazing, and then they die off". One of the last generation of these, maybe redoc or redocly now points to a casino website ;-(. I believe this is pretty isolated impact, so we can use it and toss it if needed. Good question on the phone home, I'll look.

@epugh

epugh commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

So, @gerlowskija noticed that the standalone.js file is 3.4 MB... I was trying to make this totally standalone, not part of our current Admin UI (with some sort of idea that it was easier to get rid of it if the project stagnates or if we watn to eliminate our Admin UI)... However, I'm wondering if we would rather make it part of the existing Admin UI, which primairly I think would mean that we would have it more fully in the left nav AND we wouldn't need to check in the standalone.js file??? Which maybe is what you were meaning @janhoy ?

@epugh

epugh commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Scalar is "having a moment" (not that should be why we use it), but I've seen it behind two other websites recently.. ;-)

@janhoy

janhoy commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Yes, I'd prefer it ships as a standard feature of Admin UI. Or alternatively its own servlet next to /solr, but always available.

@epugh

epugh commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Okay... @gerlowskija I moved it to being built via our build tooling, no more GIANT file. @janhoy it's now a standalone html app, but integrated more closely!

@epugh

epugh commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Maybe nice to haves?

@epugh epugh unassigned janhoy Nov 4, 2026
@epugh
epugh requested a review from janhoy November 4, 2026 14:25
@gerlowskija

Copy link
Copy Markdown
Contributor

What's the state of this PR @epugh ? Is it something you're looking to merge soon, or is truly just a demo as the title/description suggest and not quite ready for committing yet?

@epugh

epugh commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Maybe in a future PR we actually show teh Java and JavaScript clients in the UI?

image

@epugh

epugh commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@epugh epugh changed the title Api explorer demo (based on Scalar OpenAPI UI) API Explorer for V2 APIs (based on Scalar OpenAPI UI) Nov 4, 2026
@epugh

epugh commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Okay, I'm going to call this "done" for now and ready for review. Lots of cool ideas of where we can go, but hoenstly, jstu getting this in will be awesome.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Scalar’s test requests omit the Admin UI’s authentication credentials, while missing browser coverage leaves explorer loading, spec rendering, navigation, and CSP framing unverified.

2 open issues
What changed in this PR

Adds a Scalar-based V2 API Explorer to the legacy Solr Admin UI, letting users browse the bundled OpenAPI specification and send requests to the running node.

Changes:

  • Embeds Scalar in an iframe to isolate its navigation from AngularJS.
  • Downloads and packages Scalar with the generated specification, and adjusts framing policies.
  • Adds test asset-serving support, documentation, and license notices.
File Description
solr/​webapp/​web/​partials/​api-explorer.html Embeds the explorer iframe.
solr/​webapp/​web/​libs/​scalar/​scalar-init.js Configures Scalar for local use.
solr/​webapp/​web/​libs/​scalar/​index.html Hosts the standalone explorer.
solr/​webapp/​web/​js/​angular/​controllers/​api-explorer.js Sets the active navigation item.
solr/​webapp/​web/​js/​angular/​app.js Registers the explorer route.
solr/​webapp/​web/​index.html Loads the controller and adds navigation.
solr/​webapp/​web/​css/​angular/​menu.css Adds the explorer menu icon.
solr/​webapp/​web/​css/​angular/​common.css Sets the iframe height.
solr/​webapp/​src/​test/​org/​apache/​solr/​webapp/​AdminUiTestBase.java Serves Scalar assets for browser tests.
solr/​webapp/​scalar/​build.gradle.kts Downloads and exports the Scalar bundle.
solr/​webapp/​gradle.lockfile Records the OpenAPI configuration.
solr/​webapp/​build.gradle Packages explorer assets and wires test inputs.
solr/​solr-ref-guide/​modules/​getting-started/​pages/​solr-admin-ui.adoc Documents explorer usage.
solr/​server/​etc/​jetty.xml Allows same-origin framing of the Scalar page.
solr/​core/​src/​java/​org/​apache/​solr/​servlet/​LoadAdminUiServlet.java Allows the Admin UI to load same-origin frames.
solr/​api/​src/​java/​org/​apache/​solr/​client/​api/​util/​ApiMetadata.java Sets the specification’s server URL to /api.
settings.gradle Includes the Scalar subproject.
NOTICE.txt Adds Scalar attribution and MIT license text.
gradle/​libs.versions.toml Pins the Scalar dependency version.
dev-docs/​local-api-explorer.adoc Explains usage and maintenance.
dev-docs/​apis.adoc Links to explorer documentation.
changelog/​unreleased/​PR-5201-api-explorer.yml Records the new feature.

Review effort: Balanced

Comment thread solr/webapp/web/js/angular/app.js Resolved
@janhoy

janhoy commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Very cool. I took it for a spin. Should the iframe panel also have a link to open scalar directly in full-screen, which would give more space on small screens?

@epugh

epugh commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

@janhoy wpuld love a plus one if possible! I think it's ready to ship.

Scalar's "Test Request" issues its own fetch() calls, bypassing the Admin
UI's Angular/superagent interceptors (app.js's httpInterceptor and
solrApi.ApiClient.instance.plugins), so after logging in via BasicAuth or
JWT, testing a request in the explorer sent no credentials at all,
resulting in 401s or a browser auth popup.

Use Scalar's onBeforeRequest hook to read sessionStorage['auth.header']
fresh on every request (same as the existing interceptors do, so
login/logout is respected) and attach it, plus the X-Requested-With
header the rest of the Admin UI already sends to suppress the browser's
native BasicAuth popup. Credentials are only ever attached when the
request targets this same origin, never a different server a user might
select or type into the explorer.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
@nick-boss-tech

Copy link
Copy Markdown
Contributor

Hi @epugh,

[P2] Explorer requests do not use the Admin UI’s credentials. The Scalar initializer runs outside the Admin UI’s request interceptors and does not attach the Basic or JWT credentials stored in session storage. Authenticated API calls may therefore receive a 401 or a separate browser challenge. This was already raised on the PR. The author reports a fix, but it is not present at the verified PR head.

[P2] The explorer has no behavior test. The PR adds infrastructure to serve its generated assets during browser tests, but no test opens the explorer, renders the spec, or sends a request. The author reports that “Test Request” hangs; I did not independently reproduce or diagnose it. A focused browser test should cover the packaged assets, production framing policy, a harmless request, and authenticated use. This gap was also raised on the PR.

AI-generated.

@epugh

epugh commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Hi @epugh,

[P2] Explorer requests do not use the Admin UI’s credentials. The Scalar initializer runs outside the Admin UI’s request interceptors and does not attach the Basic or JWT credentials stored in session storage. Authenticated API calls may therefore receive a 401 or a separate browser challenge. This was already raised on the PR. The author reports a fix, but it is not present at the verified PR head.

[P2] The explorer has no behavior test. The PR adds infrastructure to serve its generated assets during browser tests, but no test opens the explorer, renders the spec, or sends a request. The author reports that “Test Request” hangs; I did not independently reproduce or diagnose it. A focused browser test should cover the packaged assets, production framing policy, a harmless request, and authenticated use. This gap was also raised on the PR.

AI-generated.

Hey @nick-boss-tech I'd love you to take a stab at those two P2's... I burned a bunch of tokens + manual work trying to get the Scalar Initilizaer to actually work... What I foudn was that with basic auth, I would just always get the browser popup when I wen to send the request.. maybe due to the iframe? I finally decided I could live with it, but it would be much nicer if it just worked...

@nick-boss-tech

nick-boss-tech commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖 (reviewed by Nick Shanin)

Hi @epugh, I took a stab at the two issues. The proposed changes forward the current Admin UI credentials and X-Requested-With on same-origin Scalar requests, and add a browser test that sends a collections request and navigates back.

If you would like to take them onto your branch, with your branch at 3f9faa9e9861ce28f3ede3f4305bd91b6e297463:

git switch api-explorer-demo
git fetch https://github.com/nick-boss-tech/solr.git pr-5201-auth-browser-fix
git merge --ff-only 0355023c3170c87a84cd9e5688ae6b4f3e4df3ae

On Linux at that head, the focused explorer test passed, as did the security and neighboring smoke tests (2 and 5 tests). Tidy made no changes, and the root check passed with only tests excluded. A packaged Basic Auth browser run loaded the explorer under the production framing policy, sent a successful collections request, and returned to the Admin UI. The unchanged new test reached the request and failed waiting for the response on the original PR head. JWT was not tested.

One behavior to consider: after a password change, an explorer request receives 401 but does not itself clear the old credential or open login. The next Admin UI request triggers login, and the explorer works again after re-authentication. Would you want the explorer to trigger the same recovery directly?

If you prefer, I could open a new PR which you could approve instead of this one. Let me know how else I could help out.

Comment thread gradle/libs.versions.toml Outdated
nodejs = "22.18.0"
onnx = "1.29.0"
openapi = "7.25.0"
scalar-api-reference = "1.46.4"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for-my-knowledge]
where do i verify that this is the most latest available stable version? can you help me with the gradle dependency page of this artifact.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we just Google!

Comment on lines +75 to +77
// frame-src: the Admin UI's API Explorer loads a same-origin page in an
// iframe (Scalar manages its own URL hash for deep-linking, which conflicts
// with AngularJS's ngRoute if mounted directly into the app instead).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ques] is this comment suited here? or should be in some dev docs?

if i am right, we are adding frame-src 'self'; entry here. there were many entries here already, so just adding for 1 we should avoid.

A convenience redirect is also supported, so simply accessing the Admin UI at `\http://hostname:port/` will also redirect to `\http://hostname:port/solr/#/`.
====

=== API Explorer

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be refreshing the base image on this adoc as well to keep the docs consistent with latest state?

image::solr-admin-ui/dashboard.png[image,height=400] ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should...

Comment on lines +52 to +54
The *API Explorer* item in the Admin UI's left-hand navigation opens interactive documentation for Solr's v2 API.
It renders the OpenAPI specification bundled with Solr and lets you browse endpoints and send requests to the running instance.
Requests use the instance's authentication and authorization rules and can modify its data or configuration.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see other sections also have a screenshot of their UI, should we also keep home page screenshot of the api explorer in this section.

something similar to this should work?

Screenshot 2026-11-13 at 12 58 44 AM

Comment thread solr/webapp/scalar/build.gradle.kts Resolved

#menu #threads.global p a { background-image: url( ../../img/ico/ui-accordion.png ); }

#menu #api-explorer.global p a { background-image: url( ../../img/ico/openapi.png ); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2026-11-13 at 1 04 45 AM

personally, the openAPI icon looks little different from how our exising icons are.

[my-doubt] do we have any designer in our community as well, who helps us in making these UI/UX changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We unforutnantly don't have a designer...

Comment thread gradle/libs.versions.toml Resolved
== Usage

Build and start a local Solr with `./gradlew dev` and `bin/solr start -c`.
Open the *API Explorer* item in the Admin UI's left nav to browse endpoints and send requests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add 1 or 2 screenshots as well?

history, with no shared hash to contend over.
-->
<div id="app"></div>
<script src="standalone.js" charset="UTF-8"></script>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for-my-knowledge] we dont have this file: 'standalong.js' in our codebase.

how this linking works then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brought in at build time by Gradle.

@jaykay12 jaykay12 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets merge latest main as well.

epugh and others added 2 commits November 22, 2026 11:33
Register Scalar's request callback at the top level so same-origin requests
use the current Admin UI credentials and suppress native BasicAuth prompts.

Cover authenticated collections requests and navigation in the browser,
isolate browser state between tests, and restore version catalog ordering.

Co-authored-by: Nick Shanin <nick.boss.us@gmail.com>
@epugh

epugh commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

okay, tested and auth is now working... loving the bin/solr start -e secure featuere for testing this type of thing.... goign to merge next week if no one speaks up...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking about deleting this file... I'm not sure it's really provindg a ton of value? And one more thing to update? I could see dev-docs just exploding with ai generated docs...

The explorer has to run as its own page in an iframe because Scalar and
AngularJS's ngRoute both rewrite window.location.hash. :solr:webapp:scalar
now owns everything the explorer needs: index.html, scalar-init.js, the
bundled-license audit files, and the Scalar bundle. :solr:webapp mounts
the module's output at libs/scalar.

The bundle is fetched as the pinned npm archive through a Gradle Ivy
repository instead of running npm, honouring the existing
solr.npm.registry / SOLR_NPM_REGISTRY mirror override. As with the other
Admin UI JavaScript libraries, licensing is recorded in the root
LICENSE/NOTICE files, with the full third-party inventory shipped next to
the bundle; nothing is wired into the jar license checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm

@epugh epugh left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like more lines than it should be....

@epugh

epugh commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@janhoy so the iframe is nice if you have a secure solr, you don't have to reenter your credentials. Teh flip side is that we don't have as much space in the UI... I'm really on the fence about which way to go... Popping out to another tab gives a bigger space.... Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

admin-ui cat:api dependencies Dependency upgrades documentation Improvements or additions to documentation jetty-server tests tool:build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants